home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 376-400 / disk_386 / xlispstat / src2.lzh / XLisp-Stat / xsiviewintrn.c < prev    next >
C/C++ Source or Header  |  1990-10-07  |  22KB  |  804 lines

  1. /* xsiviewinternal - XLISP interface to IVIEW dynamic graphics package.*/
  2. /* XLISP-STAT 2.1 Copyright (c) 1990, by Luke Tierney                  */
  3. /* Additions to Xlisp 2.1, Copyright (c) 1989 by David Michael Betz    */
  4. /* You may give out copies of this software; for conditions see the    */
  5. /* file COPYING included with this distribution.                       */
  6.  
  7. #include "xlisp.h"
  8. #include "osdef.h"
  9. #ifdef ANSI
  10. #include "xlproto.h"
  11. #include "xlsproto.h"
  12. #include "iviewproto.h"
  13. #include "Stproto.h"
  14. #else
  15. #include "xlfun.h"
  16. #include "xlsfun.h"
  17. #include "iviewfun.h"
  18. #include "Stfun.h"
  19. #endif ANSI
  20. #include "xlsvar.h"
  21.  
  22. /* forward declarations */
  23. #ifdef ANSI
  24. void set_mode_cursor(LVAL);
  25. int OverlayMouse(LVAL);
  26. LVAL state_access(int),iview_axis(int),brush(int), multi_state_set(int),
  27.      get_mouse_selector(LVAL,MouseEventType),iview_std_mouse(MouseEventType);
  28. #else
  29. void set_mode_cursor();
  30. int OverlayMouse();
  31. LVAL state_access(),iview_axis(),brush(), multi_state_set(),
  32.      get_mouse_selector(),iview_std_mouse();
  33. #endif ANSI
  34.  
  35. /**************************************************************************/
  36. /**                                                                      **/
  37. /**                       IView Creation Functions                       **/
  38. /**                                                                      **/
  39. /**************************************************************************/
  40.  
  41. /* :ISNEW message for GRAPH-PROTO */
  42. LVAL iview_isnew()
  43. {
  44.   LVAL object, vars, args;
  45.   int show;
  46.   
  47.   object = xlgaobject();
  48.   vars = xlgafixnum();
  49.   if (getfixnum(vars) < 0) xlerror("not a nonnegative integer", vars);
  50.   else set_slot_value(object, s_number_of_variables, vars);
  51.   show = (xsboolkey(sk_show, TRUE)) ? TRUE : FALSE;
  52.   
  53.   object_isnew(object);
  54.   get_iview_keys(object);
  55.   initialize_graph(object);
  56.   send_message(object, sk_new_menu);
  57.  
  58.   xlsave1(args);
  59.   if (show) args = consa(s_true);
  60.   else args = consa(NIL);
  61.   args = cons(sk_show, args);
  62.   apply_send(object, sk_allocate, args);
  63.   xlpop();
  64.   
  65.   return(object);
  66. }
  67.  
  68. void initialize_graph(object)
  69.     LVAL object;
  70. {
  71.   initialize_graph_window(object);
  72. }
  73.  
  74. /* :ALLOCATE message for GRAPH-PROTO */
  75. LVAL iview_allocate()
  76. {
  77.   LVAL object;
  78.   IVIEW_WINDOW w;
  79.   int show;
  80.   
  81.   object = xlgaobject();
  82.   show = xsboolkey(sk_show, TRUE);
  83.   
  84.   w = IViewNew(object);
  85.   initialize_iview(w, object);
  86.   /* use StShowWindow to show (map) window but NOT send :resize or :redraw */
  87.   if (show) StShowWindow(w);
  88.   
  89.   return(object);
  90. }
  91.  
  92. void get_iview_keys(object)
  93.     LVAL object;
  94. {
  95.   LVAL arg;
  96.   
  97.   if (xlgetkeyarg(sk_variable_labels, &arg))
  98.     set_slot_value(object, s_variable_labels, coerce_to_vector(arg));
  99.   if (xlgetkeyarg(sk_scale, &arg)) {
  100.     if (arg != s_fixed && arg != s_variable) arg = NIL;
  101.     set_slot_value(object, s_scale_type, arg);
  102.   }
  103. }
  104.  
  105. #ifdef OLDLINKS
  106. void IViewAdjustOwnScreen(w)
  107.      IVIEW_WINDOW w;
  108. {
  109.   LVAL object = (LVAL) IViewWindowGetObject(w);
  110.   
  111.   if (mobject_p(object))
  112.     send_message(object, sk_adjust_screen);
  113. }
  114. #endif /* OLDLINKS */
  115.  
  116. void IViewMarkPointsInRect(w, left, top, width, height)
  117.     IVIEW_WINDOW w;
  118.     int left, top, width, height;
  119. {
  120.   LVAL argv[6], Lleft, Ltop, Lwidth, Lheight;
  121.   
  122.   xlstkcheck(4);
  123.   xlsave(Lleft);
  124.   xlsave(Ltop);
  125.   xlsave(Lwidth);
  126.   xlsave(Lheight);
  127.   argv[0] = (LVAL) IViewWindowGetObject(w);
  128.   argv[1] = sk_mark_points_in_rect;
  129.   argv[2] = Lleft = cvfixnum((FIXTYPE) left);
  130.   argv[3] = Ltop = cvfixnum((FIXTYPE) top);
  131.   argv[4] = Lwidth = cvfixnum((FIXTYPE) width);
  132.   argv[5] = Lheight = cvfixnum((FIXTYPE) height);
  133.   xscallsubrvec(xmsend, 6, argv);
  134.   xlpopn(4);
  135. }
  136.  
  137. LVAL encode_point_state(state)
  138.     PointState state;
  139. {
  140.   switch (state) {
  141.   case pointInvisible: return(s_invisible);
  142.   case pointNormal:    return(s_normal);
  143.   case pointHilited:   return(s_hilited);
  144.   case pointSelected:  return(s_selected);
  145.   default: xlfail("unknown point state");
  146.   }
  147. }
  148.  
  149. void IViewAdjustPointsInRect(w, left, top, width, height, state)
  150.     IVIEW_WINDOW w;
  151.     int left, top, width, height;
  152.     PointState state;
  153. {
  154.   LVAL argv[7], Lleft, Ltop, Lwidth, Lheight;
  155.   
  156.   xlstkcheck(4);
  157.   xlsave(Lleft);
  158.   xlsave(Ltop);
  159.   xlsave(Lwidth);
  160.   xlsave(Lheight);
  161.   argv[0] = (LVAL) IViewWindowGetObject(w);
  162.   argv[1] = sk_adjust_points_in_rect;
  163.   argv[2] = Lleft = cvfixnum((FIXTYPE) left);
  164.   argv[3] = Ltop = cvfixnum((FIXTYPE) top);
  165.   argv[4] = Lwidth = cvfixnum((FIXTYPE) width);
  166.   argv[5] = Lheight = cvfixnum((FIXTYPE) height);
  167.   argv[6] = encode_point_state(state);
  168.   xscallsubrvec(xmsend, 7, argv);
  169.   xlpopn(4);
  170. }
  171.  
  172. void IViewAdjustOwnScreenPoint(w, point)
  173.     IVIEW_WINDOW w;
  174.     int point;
  175. {
  176.   LVAL object = (LVAL) IViewWindowGetObject(w);
  177.  
  178.   if (mobject_p(object))
  179.     send_message1(object, sk_adjust_screen_point, point);
  180. }
  181.  
  182. void IViewUnselectAllPoints(w)
  183.     IVIEW_WINDOW w;
  184. {
  185.   LVAL object = (LVAL) IViewWindowGetObject(w);
  186.  
  187.   if (mobject_p(object))
  188.     send_message(object, sk_unselect_all_points);
  189. }
  190.  
  191. void initialize_iview(w, object)
  192.     IVIEW_WINDOW w;
  193.     LVAL object;
  194. {
  195.   int i, vars, len;
  196.   LVAL labels;
  197.   MouseMode mode;
  198.   
  199.   labels = slot_value(object, s_variable_labels);
  200.   if (vectorp(labels)) {
  201.     len = getsize(labels);
  202.     vars = IViewNumVariables(w);
  203.     for (i = 0; i < len && i < vars; i++) {
  204.       if (stringp(getelement(labels, i)))
  205.         IViewSetVariableLabel(w, i, (char *) getstring(getelement(labels, i)));
  206.     }
  207.   }
  208.   else set_slot_value(object, s_variable_labels, NIL);
  209.   
  210.   if (slot_value(object, s_showing_labels) != NIL)
  211.     IViewSetShowingLabels(w, TRUE);
  212.  
  213.   IViewSetFixedAspect(w, (slot_value(object, s_fixed_aspect) != NIL));
  214.  
  215.   if (slot_value(object, s_mouse_mode) == s_brushing) mode = brushing;
  216.   else if (slot_value(object, s_mouse_mode) == s_selecting) mode = selecting;
  217.   else mode = usermode;
  218.   IViewSetMouseMode(w, mode);
  219. }
  220.  
  221. void get_iview_ivars(object, vars)
  222.     LVAL object;
  223.     int *vars;
  224. {
  225.   LVAL num_variables;
  226.   
  227.   num_variables = slot_value(object, s_number_of_variables);
  228.   if (! fixp(num_variables) || getfixnum(num_variables) < 0)
  229.     xlerror("number of variables is not a nonnegative integer", num_variables);
  230.   *vars = getfixnum(num_variables);
  231. }
  232.  
  233. /* :SHOW-WINDOW message for GRAPH-PROTO */
  234. LVAL iview_window_show_window()
  235. {
  236.   LVAL object = xlgaobject();
  237.   IVIEW_WINDOW w = GETWINDOWADDRESS(object);
  238.   /* char */ StGWWinInfo *gwinfo = StGWObWinInfo(object); /* changed JKL */
  239.  
  240.   if (w == nil) send_message(object, sk_allocate);
  241.   StGWShowWindow(gwinfo);
  242.   return(NIL);
  243. }
  244.  
  245. /**************************************************************************/
  246. /**                                                                      **/
  247. /**                 IView State Accessors and Mutators                   **/
  248. /**                                                                      **/
  249. /**************************************************************************/
  250.  
  251. static LVAL state_access(which)
  252.     int which;
  253. {
  254.   /*char*/ StGWWinInfo *gwinfo; /* changed JKL */
  255.   LVAL list, arg, object;
  256.   int a, b, c, d, set = FALSE;
  257.   
  258.   object = xlgaobject();
  259.   gwinfo = StGWObWinInfo(object);
  260.   if (moreargs()) {
  261.     set = TRUE;
  262.     a = getfixnum(xlgafixnum());
  263.     b = getfixnum(xlgafixnum());
  264.     if (which == 'R' || which == 'M') {
  265.       c = getfixnum(xlgafixnum());
  266.       d = getfixnum(xlgafixnum());
  267.     }
  268.   }
  269.   
  270.   if (set)
  271.     switch (which) {
  272.     case 'R': StGrSetContentRect(gwinfo, a, b, c, d); break;
  273.     case 'O': StGrSetContentOrigin(gwinfo, a, b);     break;
  274.     case 'V': StGrSetContentVariables(gwinfo, a, b);  break;
  275.     case 'C': StGrSetClickRange(gwinfo, a, b);        break;
  276.     case 'M': 
  277.       StGrSetMargin(gwinfo, a, b, c, d);
  278.       if (! xlgetkeyarg(sk_draw, &arg)) arg = s_true;
  279.       if (arg != NIL) send_message(object, sk_resize);
  280.       if (arg != NIL) send_message(object, sk_redraw);  
  281.       break;
  282.     }
  283.     
  284.   switch (which) {
  285.   case 'R': StGrGetContentRect(gwinfo, &a, &b, &c, &d); break;
  286.   case 'O': StGrGetContentOrigin(gwinfo, &a, &b);       break;
  287.   case 'V': StGrGetContentVariables(gwinfo, &a, &b);    break;
  288.   case 'C': StGrGetClickRange(gwinfo, &a, &b);          break;
  289.   case 'M': StGrGetMargin(gwinfo, &a, &b, &c, &d);      break;
  290.   }
  291.   
  292.   if (which == 'R' || which == 'M') list = integer_list_4(a, b, c, d);
  293.   else list = integer_list_2(a, b);
  294.   
  295.   return(list);
  296. }
  297.  
  298. LVAL iview_content_rect()      { return(state_access('R')); }
  299. LVAL iview_content_origin()    { return(state_access('O')); }
  300. LVAL iview_content_variables() { return(state_access('V')); }
  301. LVAL iview_click_range()       { return(state_access('C')); }
  302.  
  303. LVAL iview_mouse_mode()
  304. {
  305.   IVIEW_WINDOW w;
  306.   LVAL modesym, object;
  307.   MouseMode mode;
  308.   int set = FALSE;
  309.   
  310.   object = xlgaobject();
  311.   w = get_iview_address(object);
  312.   if (moreargs()) {
  313.     set = TRUE;
  314.     modesym = xlgasymbol();
  315.   }
  316.   xllastarg();
  317.   
  318.   if (set) {
  319.     if (modesym == s_selecting) mode = selecting;
  320.     else if (modesym == s_brushing) mode = brushing;
  321.     else mode = usermode;
  322.     set_slot_value(object, s_mouse_mode, modesym);
  323.     IViewSetMouseMode(w, mode);
  324.     set_mode_cursor(object);
  325.   }
  326.   
  327.   switch (IViewMouseMode(w)) {
  328.   case selecting: modesym = s_selecting; break;
  329.   case brushing:  modesym = s_brushing;  break;
  330.   default: modesym = slot_value(object, s_mouse_mode);
  331.   }
  332.   
  333.   return(modesym);
  334. }
  335.  
  336. LVAL iview_showing_labels()
  337. {
  338.   IVIEW_WINDOW w;
  339.   int set = FALSE, show;
  340.   LVAL object;
  341.   
  342.   object = xlgaobject();
  343.   w = get_iview_address(object);
  344.   if (moreargs()) {
  345.     set = TRUE;
  346.     show = (xlgetarg() != NIL) ? TRUE : FALSE;
  347.   }
  348.   xllastarg();
  349.   
  350.   if (set)  IViewSetShowingLabels(w, show);
  351.   return((IViewShowingLabels(w)) ? s_true : NIL);
  352. }
  353.  
  354. LVAL iview_margin()      { return(state_access('M')); }
  355.  
  356. LVAL iview_fixed_aspect()
  357. {
  358.   IVIEW_WINDOW w;
  359.   LVAL object;
  360.   int set = FALSE, fixed;
  361.   
  362.   object = xlgaobject();
  363.   if (moreargs()) {
  364.     set = TRUE;
  365.     fixed = (xlgetarg() != NIL) ? TRUE : FALSE;
  366.   }
  367.   xllastarg();
  368.   w = GETIVIEWADDRESS(object);
  369.   
  370.   if (w != nil) {
  371.     if (set) {
  372.       set_slot_value(object, s_fixed_aspect, (fixed) ? s_true : NIL);
  373.       IViewSetFixedAspect(w, fixed);
  374.       StGWObResize(object);
  375.       StGWObRedraw(object);
  376.     }
  377.     return((IViewFixedAspect(w)) ? s_true : NIL);
  378.   }
  379.   else {
  380.     if (set) set_slot_value(object, s_fixed_aspect, (fixed) ? s_true : NIL);
  381.     return(slot_value(object, s_fixed_aspect));
  382.   }
  383. }
  384.  
  385. LVAL iview_dirty()
  386. {
  387.   /*char*/ StGWWinInfo *gwinfo; /* changed JKL */
  388.   LVAL object;
  389.   int set;
  390.   
  391.   object = xlgaobject();
  392.   set = moreargs();
  393.   gwinfo = StGWObWinInfo(object);
  394.   if (set) StGrSetDirty(gwinfo, (xlgetarg() != NIL) ? TRUE : FALSE);
  395.   return(StGrDirty(gwinfo) ? s_true : NIL);
  396. }
  397.  
  398. /**************************************************************************/
  399. /**                                                                      **/
  400. /**                            Axis Functions                            **/
  401. /**                                                                      **/
  402. /**************************************************************************/
  403.  
  404. static LVAL iview_axis(which)
  405.     int which;
  406. {
  407.   IVIEW_WINDOW w;
  408.   int showing, labeled, ticks, set = FALSE, draw;
  409.   LVAL object, temp, result;
  410.   
  411.   object = xlgaobject();
  412.   w = get_iview_address(object);
  413.   if (moreargs()) {
  414.     set = TRUE;
  415.     showing = (xlgetarg() != NIL) ? TRUE : FALSE;
  416.     labeled = (moreargs() && xlgetarg() != NIL) ? TRUE : FALSE;
  417.     ticks = (moreargs()) ? getfixnum(xlgafixnum()) : 4;
  418.   }
  419.   
  420.   if (set) {
  421.     switch (which) {
  422.     case 'X': IViewSetXaxis(w, showing, labeled, ticks); break;
  423.     case 'Y': IViewSetYaxis(w, showing, labeled, ticks); break;
  424.     }
  425.     draw = draw_key_arg(TRUE);
  426.     StGWObResize(object);
  427.     check_redraw(object, draw, FALSE);
  428.   }
  429.   
  430.   switch(which) {
  431.   case 'X': IViewGetXaxis(w, &showing, &labeled, &ticks); break;
  432.   case 'Y': IViewGetYaxis(w, &showing, &labeled, &ticks); break;
  433.   }
  434.   
  435.   xlstkcheck(2);
  436.   xlsave(result);
  437.   xlsave(temp);
  438.   temp = cvfixnum((FIXTYPE) ticks); result = consa(temp);
  439.   temp = (labeled) ? s_true : NIL; result = cons(temp, result);
  440.   temp = (showing) ? s_true : NIL; result = cons(temp, result);
  441.   xlpopn(2);
  442.  
  443.   return(result);
  444. }
  445.  
  446. LVAL iview_x_axis() { return(iview_axis('X')); }
  447. LVAL iview_y_axis() { return(iview_axis('Y')); }
  448.  
  449. /**************************************************************************/
  450. /**                                                                      **/
  451. /**                           Brush Functions                            **/
  452. /**                                                                      **/
  453. /**************************************************************************/
  454.  
  455. static LVAL brush(which)
  456.     int which;
  457. {
  458.   IVIEW_WINDOW w;
  459.   int x, y, width, height, set = FALSE;
  460.   LVAL result;
  461.   
  462.   w = get_iview_address(xlgaobject());
  463.   if (which == 'B' && moreargs()) {
  464.     set = TRUE;
  465.     x = getfixnum(xlgafixnum());
  466.     y = getfixnum(xlgafixnum());
  467.     width = getfixnum(xlgafixnum());
  468.     height = getfixnum(xlgafixnum());
  469.   }
  470.   else if (which == 'M') {
  471.     x = getfixnum(xlgafixnum());
  472.     y = getfixnum(xlgafixnum());
  473.   }
  474.   xllastarg();
  475.   
  476.   if (set) IViewSetBrush(w, x, y, width, height);
  477.   
  478.   switch (which) {
  479.   case 'B': IViewGetBrush(w, &x, &y, &width, &height); break;
  480.   case 'E': IViewEraseBrush(w); break;
  481.   case 'D': IViewDrawBrush(w); break;
  482.   case 'M': IViewMoveBrush(w, x, y); break;
  483.   }
  484.   
  485.   if (which == 'B') result = integer_list_4(x, y, width, height);
  486.   else result = NIL;
  487.   
  488.   return(result);
  489. }
  490.  
  491. LVAL iview_brush()       { return(brush('B')); }
  492. LVAL iview_erase_brush() { return(brush('E')); }
  493. LVAL iview_draw_brush()  { return(brush('D')); }
  494. LVAL iview_move_brush()  { return(brush('M')); }
  495.  
  496. LVAL iview_resize_brush()
  497. {
  498.   IVIEW_WINDOW w;
  499.   int x, y, width, height, new_width, new_height, changed;
  500.   
  501.   w = get_iview_address(xlgaobject());
  502.   changed = IViewGetNewBrushSize(w, &new_width, &new_height);
  503.   if (changed) {
  504.     IViewGetBrush(w, &x, &y, &width, &height);
  505.     IViewSetBrush(w, x, y, new_width, new_height);
  506.   }
  507.   return((changed) ? s_true : NIL);
  508. }
  509.  
  510. /**************************************************************************/
  511. /**                                                                      **/
  512. /**                      Mouse Action Functions                          **/
  513. /**                                                                      **/
  514. /**************************************************************************/
  515.  
  516. static LVAL get_mouse_selector(object, type)
  517.      LVAL object;
  518.      MouseEventType type;
  519. {
  520.   LVAL selector, mode, list, entry;
  521.   
  522.   mode = slot_value(object, s_mouse_mode);
  523.   list = slot_value(object, s_mode_list);
  524.   for (selector = NIL; consp(list); list = cdr(list)) {
  525.     entry = car(list);
  526.     if (consp(entry) && car(entry) == mode) {
  527.       if (type == MouseClick) {
  528.     if (llength(entry) >= 4) selector = car(cdr(cdr(cdr(entry))));
  529.       }
  530.       else {
  531.     if (llength(entry) >= 5) selector = car(cdr(cdr(cdr(cdr(entry)))));
  532.       }
  533.       break;
  534.     }
  535.   }
  536.   return(selector);
  537. }
  538.  
  539. void IViewDoClick(object)
  540.      LVAL object;
  541. {
  542.   LVAL selector = get_mouse_selector(object, MouseClick);
  543.  
  544.   if (! OverlayMouse(object) && symbolp(selector))
  545.     send_message_stk(object, selector);
  546. }
  547.  
  548. void IViewDoMotion(object)
  549.      LVAL object;
  550. {
  551.   LVAL selector = get_mouse_selector(object, MouseMove);
  552.  
  553.   if (symbolp(selector))
  554.     send_message_stk(object, selector);
  555. }
  556.  
  557. static int OverlayMouse(object)
  558.     LVAL object;
  559. {
  560.   LVAL argv[6], result;
  561.   int i;
  562.  
  563.   argv[0] = object;
  564.   argv[1] = sk_overlay_click;
  565.   for (i = 0; i < 4 && i < xlargc; i++)
  566.     argv[i + 2] = xlargv[i];
  567.   result = xscallsubrvec(xmsend, 6, argv);
  568.   return(result != NIL);
  569. }
  570.  
  571. LVAL iview_do_click()
  572. {
  573.   LVAL object;
  574.   
  575.   object = xlgaobject();
  576.   IViewDoClick(object);
  577.   return(NIL);
  578. }
  579.  
  580. LVAL iview_do_motion()
  581. {
  582.   LVAL object;
  583.   
  584.   object = xlgaobject();
  585.   IViewDoMotion(object);
  586.   return(NIL);
  587. }
  588.  
  589. static LVAL iview_std_mouse(type)
  590.      MouseEventType type;
  591. {
  592.   IVIEW_WINDOW w;
  593.   int x, y;
  594.   MouseClickModifier mods;
  595.   
  596.   w = get_iview_address(xlgaobject());
  597.   x = getfixnum(xlgafixnum());
  598.   y = getfixnum(xlgafixnum());
  599.   if (type == MouseClick) {
  600.     mods = (MouseClickModifier) ((xlgetarg() != NIL) ? 1 : 0);
  601.     if (xlgetarg() != NIL) mods = (MouseClickModifier) (((int) mods) + 2);
  602.   }
  603.   xllastarg();
  604.   
  605.   IViewStdMouseAction(w, x, y, type, mods);
  606.   return(NIL);
  607. }
  608.  
  609. LVAL iview_std_click()  { return(iview_std_mouse(MouseClick)); }
  610. LVAL iview_std_motion() { return(iview_std_mouse(MouseMove));  }
  611.  
  612. static LVAL multi_state_set(which)
  613.     int which;
  614. {
  615.   IVIEW_WINDOW w;
  616.   int result = FALSE;
  617.   
  618.   w = get_iview_address(xlgaobject());
  619.   xllastarg();
  620.   
  621.   switch (which) {
  622.   case 'U': IViewStdUnselectAllPoints(w); break;
  623.   case 'E': IViewEraseSelection(w);               break;
  624.   case 'M': IViewMaskSelection(w);                break;
  625.   case 'u': IViewUnmaskAllPoints(w);              break;
  626.   case 'S': IViewShowAllPoints(w);                break;
  627.   case 'A': result = IViewAllPointsShowing(w);    break;
  628.   case 'a': result = IViewAllPointsUnmasked(w);   break;
  629.   case 's': result = IViewAnyPointsSelected(w);   break;
  630.   }
  631.   return((result) ? s_true : NIL);
  632. }
  633.  
  634. LVAL iview_unselect_all_points() { return(multi_state_set('U')); }
  635. LVAL iview_erase_selection()     { return(multi_state_set('E')); }
  636. LVAL iview_mask_selection()      { return(multi_state_set('M')); }
  637. LVAL iview_unmask_all_points()   { return(multi_state_set('u')); }
  638. LVAL iview_show_all_points()     { return(multi_state_set('S')); }
  639. LVAL iview_all_points_showing()  { return(multi_state_set('A')); }
  640. LVAL iview_all_points_unmasked() { return(multi_state_set('a')); }
  641. LVAL iview_any_points_selected() { return(multi_state_set('s')); }
  642.  
  643. /*************************************************************************/
  644. /**                                                                     **/
  645. /**                      IView Linking Functions                        **/
  646. /**                                                                     **/
  647. /*************************************************************************/
  648.  
  649. #ifdef OLDLINKS
  650. LVAL iview_linked()
  651. {
  652.   IVIEW_WINDOW w;
  653.   int set = FALSE, linked;
  654.   
  655.   w = get_iview_address(xlgaobject());
  656.   if (moreargs()) {
  657.     set = TRUE;
  658.     linked = (xlgetarg() != NIL) ? TRUE : FALSE;
  659.   }
  660.   xllastarg();
  661.   
  662.   if (set) {
  663.     if (linked) IViewLinkWindow(w);
  664.     else IViewUnlinkWindow(w);
  665.   }
  666.   return(IViewIsLinked(w) ? s_true : NIL);
  667. }
  668.  
  669. LVAL iview_unlink_all_windows()
  670. {
  671.   xllastarg();
  672.   IViewUnlinkAllWindows();
  673.   return(NIL);
  674. }
  675. #else
  676. /*extern LVAL s_linked_plots, sk_links, sk_linked;
  677. extern LVAL xremove();
  678. extern long IViewGetLinks();  in headers JKL */
  679.  
  680. int IViewInternalIsLinked(w)
  681.      IVIEW_WINDOW w;
  682. {
  683.   return (IViewIsLinked(w));
  684. }
  685.  
  686. LVAL iview_linked()
  687. {
  688.   LVAL object, temp;
  689.   IVIEW_WINDOW w;
  690.   int set = FALSE, linked, i, n;
  691.   
  692.   object = xlgaobject();
  693.   w = get_iview_address(object);
  694.   if (moreargs()) {
  695.     set = TRUE;
  696.     linked = (xlgetarg() != NIL) ? TRUE : FALSE;
  697.   }
  698.   xllastarg();
  699.   
  700.   if (set) {
  701.     if (linked) {
  702.       setvalue(s_linked_plots, cons(object, getvalue(s_linked_plots)));
  703.       IViewCheckLinks(w);
  704.       n = IViewNumPoints(w);
  705.       for (i = 0; i < n; i++) IViewMatchPointState(w, i);
  706.       IViewAdjustScreens(w);
  707.     }
  708.     else {
  709.       temp = xscallsubr2(xremove, object, getvalue(s_linked_plots));
  710.       setvalue(s_linked_plots, temp);
  711.       IViewCheckLinks(w);
  712.     }
  713.   }
  714.   else IViewCheckLinks(w);
  715.   
  716.   return(IViewIsLinked(w) ? s_true : NIL);
  717. }
  718.  
  719. LVAL iview_links()
  720. {
  721.   LVAL object, links, next;
  722.   
  723.   object = xlgaobject();
  724.   links = getvalue(s_linked_plots);
  725.   for (next = links; consp(next); next = cdr(next))
  726.     if (object == car(next)) return(links);
  727.   return(NIL);
  728. }
  729.  
  730. void IViewUnlinkWindow(w)
  731.      IVIEW_WINDOW w;
  732. {
  733.   LVAL object = (LVAL) IViewWindowGetObject(w);
  734.   
  735.   if (mobject_p(object)) send_message_1L(object, sk_linked, NIL);
  736.   IViewCheckLinks(w);
  737. }
  738.  
  739. LVAL iview_unlink_all_windows()
  740. {
  741.   LVAL links = getvalue(s_linked_plots);
  742.   
  743.   xllastarg();
  744.   for (; consp(links); links = cdr(links))
  745.     send_message_1L(car(links), sk_linked, NIL);
  746.   return(NIL);
  747. }
  748.  
  749. void IViewMatchPointState(w, p)
  750.      IVIEW_WINDOW w;
  751.      unsigned p;
  752. {
  753.   IVIEW_WINDOW lw;
  754.   LVAL links, object;
  755.                /* warning: in iviewinternal.c, links is true or false JKL */
  756.   for (links = (LVAL) IViewGetLinks(w); consp(links); links = cdr(links)) {
  757.     object = car(links);
  758.     lw = GETIVIEWADDRESS(object);
  759.     if (w != lw && IViewPointState(w, p) != IViewPointState(lw, p)) {
  760.       IViewSetPointScreenState(lw, p, IViewPointState(lw, p));
  761.       IViewDataSetPointState(IViewData(lw), p, IViewPointState(w, p));
  762.       send_message1(object, sk_adjust_screen_point, p);
  763.       IViewSetPointScreenState(lw, p, IViewPointState(lw, p));
  764.     }
  765.   }
  766. }
  767.  
  768. void IViewAdjustScreens(w)
  769.     IVIEW_WINDOW w;
  770. {
  771.   LVAL links, object;
  772.  
  773.   object = (LVAL) IViewWindowGetObject(w);
  774.   if (mobject_p(object)) send_message(object, sk_adjust_screen);
  775.   if (IViewIsLinked(w)) {/* warning: in iviewinternal.c, links is true or false JKL */
  776.     for (links = (LVAL) IViewGetLinks(w); consp(links); links = cdr(links)) {
  777.       object = car(links);
  778.       if (mobject_p(object)) send_message(object, sk_adjust_screen);
  779.     }
  780.   }
  781. }
  782.  
  783. void IViewCheckLinks(w)
  784.   IVIEW_WINDOW w;
  785. {
  786.   LVAL links;
  787.    /* warning: in iviewinternal.c, links is true or false JKL */
  788.   links = send_message(IViewWindowGetObject(w), sk_links);
  789.   IViewSetLinks(w, (long)links); /* cast added JKL */
  790. }
  791. #endif OLDLINKS
  792.  
  793. /*************************************************************************/
  794. /**                                                                     **/
  795. /**                      Miscellaneous Functions                        **/
  796. /**                                                                     **/
  797. /*************************************************************************/
  798.  
  799. static void set_mode_cursor(object)
  800.     LVAL object;
  801. {
  802.   send_message(object, xlenter(":SET-MODE-CURSOR"));
  803. }
  804.